import { IPageQuery } from '@/interfaces/global';
import { configRequest } from '@/utils/request';
export interface INoticParams {
  author?: string;
  content?: string;
  id?: number;
  noticeTypeId?: number;
  publicTime?: string;
  reason?: string;
  remark?: string;
  status?: number;
  title?: string;
  unitId?: number;
}

// 保存公告内容
export function saveAnnouncement(data: INoticParams) {
  return configRequest({
    url: `/notice`,
    method: 'post',
    data
  });
}
// 修改公告内容
export function editAnnouncement(data: INoticParams) {
  return configRequest({
    url: `/notice`,
    method: 'put',
    data
  });
}
export interface ICancelParams {
  id?: number;
  reason?: string;
}
// 撤销公告内容
export function cancelAnnouncement(data: ICancelParams) {
  return configRequest({
    url: `/notice/cancel`,
    method: 'post',
    data
  });
}
// 分页查询公告内容
export function fetchAnnouncementByPage(data: IPageQuery<INoticParams>) {
  return configRequest({
    url: `/notice/page`,
    method: 'post',
    data
  });
}
// 发布公告内容
export function publishAnnouncement(id: string | number) {
  return configRequest({
    url: `/notice/publish/${id}`,
    method: 'get'
  });
}
// 根据ID查询公告内容信息
export function fetchAnnouncement(id: string | number) {
  return configRequest({
    url: `/notice/${id}`,
    method: 'get'
  });
}
// 删除公告内容
export function delectAnnouncement(id: string | number) {
  return configRequest({
    url: `/notice/${id}`,
    method: 'delete'
  });
}
